package lesson04;

import java.util.Random;

public class TestMain3 {
    public static void main(String[] args) {
//        15个数字一次随机拿出一个数字。。。拿15次拿完。
//        1~15随机数：  Random r随机类。nexint();
        int[] a2 = new int[15];
        for (int i = 0; i < a2.length; i++) {
            a2[i] = i+1;
        }
        // a2 = {1,2,3,4,5,6,7,.....}
        Random rd = new Random();
        for (int i = 0; i < a2.length;) {
            int index = rd.nextInt(a2.length); // [0, 15)
            //
            int[] newa2 = new int[a2.length - 1];
            System.out.println(a2[index]);
            System.arraycopy(a2, 0, newa2, 0, index);
            System.arraycopy(a2, index+1, newa2, index, a2.length - index - 1);

            a2 = newa2;
        }
    }
}

